var fs = require("fs");
var csv = require("fast-csv");
var iconvLit = require('iconv-lite');
var ecnm = {
    mapping: {},
    __init: function (csvPath, callback) {
        // alert(csvPath);
        var self = this;
        var path = csvPath + "/../" + '中英文数值表名对照.csv';
        var content = fs.readFileSync(path);
        content = iconvLit.decode(content, 'gbk');
        csv.fromString(content)
            .on("data", function (data) {
                self.mapping[data[0]] = data[1];
            })
            .on("end", function () {
                console.log('ecnm done');
                if (callback)
                    callback();
            });
    },

    get_csv_name:function(excelName){
        return this.mapping[excelName];
    }
}

export default ecnm;